
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>登录</title>
    <script>
        function regist() {
            location.href="regist.jsp";

        }
    </script>


</head>
<body>
<%
    //读cookies
    Cookie[] cookies = request.getCookies();
    if (cookies!=null){
        for (Cookie cookie : cookies) {
            String name = cookie.getName();
            if (name.equals("username")){
                //用户名的信息保存在域对象中
                pageContext.setAttribute("username",cookie.getValue());
            }
            if (name.equals("password")){
                //密码的信息保存到域对象中
                pageContext.setAttribute("password",cookie.getValue());
            }
        }
    }
%>
<form action="admin" method = "POST">
    <table border="1" cellspacing="0" width="500px" height="200px" align="center" cellpadding="10">
        <caption><h2>用户登录</h2></caption>
        <tr >
            <td align="center">账号:</td>
            <td>
                <input type="text" name="username" value="${username}">

            </td>
        </tr>
        <tr >
            <td align="center">密码:</td>
            <td>
                <input type="password" name="password" value="${password}">
                <input type="checkbox" name="flag" value="1">记住密码
            </td>
        </tr>
        <tr align="center">
            <td colspan="2">
                <input name="sub" type="submit" value="登录" onclick="onclicklogin()">
                <input type="button" name="btn" value="注册" onclick="regist()">
            </td>

        </tr>
    </table>
</form>
</body>
</html>
